//
//  MyAccountViewController.m
//  LineMoney
//
//  Created by 尹宁 on 16/7/18.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "MyAccountViewController.h"
#import "MyAccountTableViewCell.h"
#import "ExchangeAddViewController.h"
@interface MyAccountViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@end

@implementation MyAccountViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"我的账户";
    [self creatTableView];
//    [self creatRightButton];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)creatRightButton
{
    
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    shareButton.frame = CGRectMake(0, 0, 50, 30);
    [shareButton setTitle:@"English" forState:UIControlStateNormal];
    shareButton.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [[shareButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        NSLog(@"点击");
    }];
    UIBarButtonItem *barButtonItem1 = [[UIBarButtonItem alloc]initWithCustomView:shareButton];
    self.navigationItem.rightBarButtonItems = @[barButtonItem1];
    
}
- (void)creatTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, -20, KSCREENWIDTH, KSCREENHEIGHT) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerNib:[UINib nibWithNibName:@"MyAccountTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_tableView];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.backgroundColor = [UIColor whiteColor];
    _tableView.sectionFooterHeight = 0;
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(14, 0, 346 * KSCREENWIDTH / 375, 102 * KSCREENHEIGHT / 667)];
    UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background"]];
    imageV.frame = CGRectMake(0, 0, 346 * KSCREENWIDTH / 375, 102 * KSCREENHEIGHT / 667);
    [view addSubview:imageV];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(136 * KSCREENWIDTH / 375, 44 * KSCREENHEIGHT / 667, 105 * KSCREENWIDTH / 375, 15 * KSCREENHEIGHT / 667)];
    label.text = @"添加一个新账户";
    label.font = [UIFont systemFontOfSize:15];
    label.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 346, 102);
    [[button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        ExchangeAddViewController *exchange = [[ExchangeAddViewController alloc] init];
        [self.navigationController pushViewController:exchange animated:YES];
    }];
    [view addSubview:button];
    [imageV addSubview:label];
    _tableView.tableFooterView = view;
    
    
}



#pragma mark - TableView代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 132;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyAccountTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.BigVIew.layer.cornerRadius = 5;
    cell.BigVIew.layer.masksToBounds = YES;
    cell.BigVIew.layer.borderColor = [[UIColor colorWithRed:222 / 255.0 green:222 / 255.0 blue:222 / 255.0 alpha:1] CGColor];
    cell.BigVIew.layer.borderWidth = 0.5;
    cell.BankNumberLabel.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    if (indexPath.row == 0) {
        cell.bankNameLabel.text = @"华夏银行";
        cell.PersonNameLabel.text = @"张三";
    } else if (indexPath.row == 1) {
        cell.bankNameLabel.text = @"建设银行";
        cell.PersonNameLabel.text = @"李四";
    } else {
        cell.bankNameLabel.text = @"中国银行";
        cell.PersonNameLabel.text = @"王五";
    }
    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
